package Commands

import (
	"encoding/json"
	"fmt"
	"net"

	"hyper/supports/queue/abstruct"
	"hyper/supports/queue/factories"
	"hyper/supports/redis"
)

// redis队列消费者
func RedisCommandDemo() {
	obj := &abstruct.QueueObj{
		Name: "jybtx",
		Data: nil,
	}
	redis.ConnectRedis(net.JoinHostPort("192.168.199.251", "6379"), "", "", "", 8)

	new(factories.RedisQueue).New(obj).Consumer(func(key string) {
		data := map[string]any{}

		err := json.Unmarshal([]byte(key), &data)
		fmt.Println("consumer key:", data["data"], err)
	})
}
